import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout.Group;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;


public class MemberJoin extends JFrame {

	private JPanel contentPane;
	private JTextField tfInfo[] = new JTextField[5];
	private JPasswordField pfPw;
	private JComboBox phone;
	private JTextField textField;
	private JTextField textField_1;

	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MemberJoin frame = new MemberJoin();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}*/

	/**
	 * Create the frame.
	 */
	public MemberJoin() {
		setTitle("회원가입");
		setResizable(false);
		setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		setResizable(false);
		setBounds(100, 100, 434, 500);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		ButtonGroup group = new ButtonGroup();
		
		JButton btnNewButton = new JButton("확인");
		btnNewButton.setBounds(122, 426, 76, 23);
		contentPane.add(btnNewButton);
		
		JButton btnCancel = new JButton("취소");
		btnCancel.setBounds(226, 426, 76, 23);
		contentPane.add(btnCancel);
		btnCancel.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				int choice = JOptionPane.showConfirmDialog(null/*부모 창*/, "회원가입창을 닫으시겠어요?"/*모달창 내용*/,""/*모달창 타이틀바*/,JOptionPane.YES_NO_OPTION/*yes,no버튼만 yes,cancel,no버튼 등 선택 가능*/);
				if(choice == JOptionPane.YES_NO_OPTION){
					dispose();
				}
			}
		});  // 취소 버튼 누를 시 모달 창 띄우면서 창만 닫음
		
		
		
		JLabel lblId = new JLabel("아이디 : ");
		lblId.setBounds(27, 28, 57, 15);
		contentPane.add(lblId);
		
		tfInfo[0] = new JTextField();
		tfInfo[0].setBounds(85, 25, 100, 21);
		contentPane.add(tfInfo[0]);
		tfInfo[0].setColumns(10);
		
		JLabel lblPw = new JLabel("비밀번호 :");
		lblPw.setBounds(205, 26, 72, 15);
		contentPane.add(lblPw);
		
		JLabel lblName = new JLabel("이름 : ");
		lblName.setBounds(27, 67, 57, 15);
		contentPane.add(lblName);
		
		tfInfo[1] = new JTextField();
		tfInfo[1].setColumns(10);
		tfInfo[1].setBounds(85, 70, 100, 21);
		contentPane.add(tfInfo[1]);
		
		JLabel lblPhone = new JLabel("전화번호 :");
		lblPhone.setBounds(27, 109, 71, 15);
		contentPane.add(lblPhone);
		
		
		
		JLabel lblSex = new JLabel("성별 :");
		lblSex.setBounds(27, 154, 57, 15);
		contentPane.add(lblSex);
		
		JRadioButton rdSexM = new JRadioButton("남");
		rdSexM.setBounds(92, 150, 45, 23);
		contentPane.add(rdSexM);
		rdSexM.setSelected(true);
		
		JRadioButton rdSexF = new JRadioButton("여");
		rdSexF.setBounds(156, 150, 45, 23);
		contentPane.add(rdSexF);
		
		group.add(rdSexF);
		group.add(rdSexM);
		pfPw = new JPasswordField();
		pfPw.setBounds(279, 22, 116, 21);
		contentPane.add(pfPw);
		
		JLabel lblAddr = new JLabel("주소 :");
		lblAddr.setBounds(27, 197, 39, 15);
		contentPane.add(lblAddr);
		
		tfInfo[3] = new JTextField();
		tfInfo[3].setBounds(85, 158, 310, 21);
		contentPane.add(tfInfo[3]);
		tfInfo[3].setColumns(10);
		
		JLabel lblLoc = new JLabel("관심지역 :");
		lblLoc.setBounds(27, 240, 57, 15);
		contentPane.add(lblLoc);
		
		tfInfo[4] = new JTextField();
		tfInfo[4].setBounds(85, 201, 116, 21);
		contentPane.add(tfInfo[4]);
		tfInfo[4].setColumns(10);
		
		JLabel lblInfo = new JLabel("자기소개 :");
		lblInfo.setBounds(27, 284, 57, 15);
		contentPane.add(lblInfo);
		
		JTextArea taInfo = new JTextArea();
		taInfo.setBounds(85, 280, 310, 136);
		contentPane.add(taInfo);
		
		 phone = new JComboBox();
		 phone.addItem("02");
		 phone.addItem("031");
		 phone.addItem("041");
		 phone.addItem("042");
		 
		 phone.setBounds(100, 106, 45, 21);
		contentPane.add(phone);
		
		JLabel lblNewLabel = new JLabel("-");
		lblNewLabel.setBounds(149, 109, 57, 15);
		contentPane.add(lblNewLabel);
		
		textField = new JTextField();
		textField.setBounds(159, 106, 45, 21);
		contentPane.add(textField);
		textField.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("-");
		lblNewLabel_1.setBounds(207, 106, 9, 21);
		contentPane.add(lblNewLabel_1);
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		textField_1.setBounds(218, 106, 45, 21);
		contentPane.add(textField_1);
		
		addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				JFrame f = (JFrame)e.getSource(); // 이벤트를 발생시킨 주체가 누군지 알아냄
				int choice = JOptionPane.showConfirmDialog(null/*부모 창*/, "회원가입창을 닫으시겠어요?"/*모달창 내용*/,""/*모달창 타이틀바*/,JOptionPane.YES_NO_OPTION/*yes,no버튼만 yes,cancel,no버튼 등 선택 가능*/);
				//확인, 취소 버튼으로 이루어진 대화상자를 모달창으로 표시 \ 모달창 : 모달창이 뜨면 뒤에 창에서 어떠한 행동도 할 수 없음 모달창만 컨트롤 가능
				if(choice == JOptionPane.YES_NO_OPTION){
					dispose();
				}
			}
		}); // x를 누르면 확인 모달창 나오고 닫힘
		
	}
}
